package com.powerwyx.shortlink.admin.remote;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powerwyx.shortlink.admin.common.convention.result.Result;
import com.powerwyx.shortlink.admin.config.OpenFeignConfiguration;
import com.powerwyx.shortlink.admin.remote.dto.*;
import com.powerwyx.shortlink.admin.remote.vo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 王艺锡
 * @version 1.0
 */
@FeignClient(
        value = "short-link-project",
        url = "${aggregation.remote-url:}",
        configuration = OpenFeignConfiguration.class
)
public interface ShortLinkActualRemoteService {
    /**
     * 创建短链接
     *
     * @param shortLinkCreateDTO
     * @return
     */
    @PostMapping("/api/shortlink/v1/create")
    Result<ShortLinkCreateVO> createShortLink(@RequestBody ShortLinkCreateDTO shortLinkCreateDTO);


    /**
     * 批量创建短链接
     */
    @PostMapping("/api/short-link/v1/create/batch")
    Result<ShortLinkBatchCreateVO> batchCreateShortLink(@RequestBody ShortLinkBatchCreateDTO requestParam);


    /**
     * 修改短链接信息
     *
     * @param shortLinkUpdateDTO
     * @return
     */
    @PostMapping("/api/shortlink/v1/update")
    Result<Void> updateShortLink(@RequestBody ShortLinkUpdateDTO shortLinkUpdateDTO);


    /**
     * 根据分组进行分页查询短链接
     *
     * @param gid
     * @param orderTag
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/api/shortlink/v1/page")
    Result<Page<ShortLinkPageVO>> shortLinkPage(
            @RequestParam("gid") String gid,
            @RequestParam("orderTag") String orderTag,
            @RequestParam("current") Long current,
            @RequestParam("size") Long size
    );


    /**
     * 查询分组内短链接数量
     *
     * @return
     */
    @GetMapping("/api/shortlink/v1/count")
    Result<List<ShortLinkCountVO>> getGroupShortLinkCount(@RequestParam("gids") List<String> gids);


    /**
     * 根据url获取网站标题
     *
     * @param url
     * @return
     */
    @GetMapping("/api/shortlink/v1/title")
    Result<String> getTitle(@RequestParam("url") String url);


    /**
     * 添加短链接至回收站
     *
     * @param recycleBinSaveDTO
     * @return
     */
    @PostMapping("/api/shortlink/v1/recyclebin/save")
    Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveDTO recycleBinSaveDTO);


    /**
     * 将短链接从回收站移出
     *
     * @param recycleBinRecoverDTO
     * @return
     */
    @PostMapping("/api/shortlink/v1/recyclebin/recover")
    Result<Void> recoverRecycleBin(@RequestBody RecycleBinRecoverDTO recycleBinRecoverDTO);


    /**
     * 删除回收站短链接
     *
     * @param recycleBinRemoveDTO
     * @return
     */
    @PostMapping("/api/shortlink/v1/recyclebin/remove")
    Result<Void> removeRecycleBin(@RequestBody RecycleBinRemoveDTO recycleBinRemoveDTO);


    /**
     * 根据分组进行分页查询回收站中的短链接
     */
    @GetMapping("/api/shortlink/v1/recyclebin/page")
    Result<Page<ShortLinkPageVO>> shortLinkRecycleBinPage(
            @RequestParam("gidList") List<String> gidList,
            @RequestParam("current") Long current,
            @RequestParam("size") Long size
    );


    /**
     * 访问单个短链接指定时间内监控数据
     */
    @GetMapping("/api/short-link/v1/stats/getSingleStats")
    Result<ShortLinkStatsVO> shortLinkStats(@RequestParam("fullShortUrl") String fullShortUrl,
                                            @RequestParam("gid") String gid,
                                            @RequestParam("enableStatus") Integer enableStatus,
                                            @RequestParam("startDate") String startDate,
                                            @RequestParam("endDate") String endDate);

    /**
     * 访问分组短链接指定时间内监控数据
     */
    @GetMapping("/api/short-link/v1/stats/group")
    Result<ShortLinkStatsVO> groupShortLinkStats(@RequestParam("gid") String gid,
                                                 @RequestParam("startDate") String startDate,
                                                 @RequestParam("endDate") String endDate);


    /**
     * 访问单个短链接指定时间内访问记录监控数据
     */
    @GetMapping("/api/short-link/v1/stats/accessrecord")
    Result<Page<ShortLinkStatsAccessRecordVO>> shortLinkStatsAccessRecord(@RequestParam("fullShortUrl") String fullShortUrl,
                                                                          @RequestParam("gid") String gid,
                                                                          @RequestParam("startDate") String startDate,
                                                                          @RequestParam("endDate") String endDate,
                                                                          @RequestParam("enableStatus") Integer enableStatus,
                                                                          @RequestParam("current") Long current,
                                                                          @RequestParam("size") Long size);


    /**
     * 访问分组短链接指定时间内访问记录监控数据
     */
    @GetMapping("/api/short-link/v1/stats/accessrecord/group")
    Result<Page<ShortLinkStatsAccessRecordVO>> groupShortLinkStatsAccessRecord(@RequestParam("gid") String gid,
                                                                               @RequestParam("startDate") String startDate,
                                                                               @RequestParam("endDate") String endDate,
                                                                               @RequestParam("current") Long current,
                                                                               @RequestParam("size") Long size);

}
